package com.gid.rcflightlogger;

import java.util.Date;

import android.content.Context;

import com.orm.androrm.BooleanField;
import com.orm.androrm.DateField;
import com.orm.androrm.ForeignKeyField;
import com.orm.androrm.IntegerField;
import com.orm.androrm.Model;
import com.orm.androrm.QuerySet;

public class Cycle extends Model {
	
	public static final QuerySet<Cycle> objects(Context context) {
		return objects(context, Cycle.class);
	}
		
	protected IntegerField mCount;
	protected IntegerField mDuration; //in seconds
	protected DateField mDate; //YYYY-MM-DDTHH:MM:SS
	protected BooleanField mFake; //if true this is a fake entry
	protected ForeignKeyField<Battery> mBattery;
	
	//constructor
	public Cycle() {
		super();
		
		mCount = new IntegerField();
		mDuration = new IntegerField();		
		mDate = new DateField();
		mFake = new BooleanField();
		mBattery = new ForeignKeyField<Battery>(Battery.class);
		reset();
	}
	
	//reset all fields to default value
	public void reset()
	{
		mCount.set(1);
		mDuration.set(0);
		mDate.set(new Date());	
		mFake.set(false);
	}

	//member access methods
	public int getCount() {
		return mCount.get();
	}
	
	public void setCount(int count) {
		mCount.set(count);
	}
	
	public int getDuration() {
		return mDuration.get();
	}
	
	public void setDuration(int duration) {
		mDuration.set(duration);
	}
	
	public Date getDate() {
		return mDate.get();
	}
	
	public void setDate(Date d) {
		mDate.set(d);
	}
	
	public boolean getFake() {
		return mFake.get();
	}
	
	public void setFake(boolean status) {
		mFake.set(status);
	}
	
	public Battery getBattery(Context context) {
		return mBattery.get(context);
	}
	
	public void setBattery(Battery b) {
		mBattery.set(b);
	}
}
